<template>
  <!-- 简单直接的加载组件，参考editCodeGen.vue中的实现 -->
  <div v-if="visible" class="zz-loading">
    <div class="loading-content">
      <div class="loading-spinner"></div>
      <span v-if="text">{{ text }}</span>
    </div>
  </div>
</template>

<script>
export default {
  name: 'zzLoading',
  props: {
    // 是否显示加载状态
    visible: {
      type: Boolean,
      default: false
    },
    // 加载文字
    text: {
      type: String,
      default: '加载中...'
    },
    // 是否全屏显示
    fullscreen: {
      type: Boolean,
      default: false
    }
  }
}
</script>

<style scoped>
.zz-loading {
  /* 默认样式与editCodeGen.vue保持一致 */
  min-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: rgba(255, 255, 255, 0.9);
  
  /* 全屏模式样式 */
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
}

/* 全屏模式特殊处理 */
.zz-loading[data-fullscreen="true"] {
  position: fixed;
  min-height: 100vh;
  z-index: 2000;
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: #606266;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #409eff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
</style>